package com.ymkyve.complex.rest;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Request;

import com.sun.jersey.api.core.HttpRequestContext;
/**
 * jersey demo
 * TODO Comment of PersonResource
 * @author wb_liang.gao
 *
 */
@Path("/person")
@Produces("text/plain; charset=UTF-8")
public class PersonResource {

	// http://127.0.0.1:8082/person/1/2
	// test

	@GET
	@Path("/{siteId}/{loginId}")
	public String getPersonByLongId(@PathParam("siteId") String siteId,
			@PathParam("loginId") String loginId) {

		return "test";
	}

	// http://127.0.0.1:8082/person/ymkyve/test?a=1&b=2
	// 12
	@SuppressWarnings("unchecked")
	@GET
	@Path("/ymkyve/test")
	public String ymkyve(@Context Request req) {
		HttpRequestContext request = (HttpRequestContext) req;
		MultivaluedMap map = request.getQueryParameters();
		String a = (String) map.getFirst("a");
		String b = (String) map.getFirst("b");
		return a + b;
	}

	// http://127.0.0.1:8082/person/ymkyve/test1?a=1&b=2
	// test1nullnull
	@GET
	@Path("/ymkyve/test1")
	public String ymkyve1(@PathParam("a") String a, @PathParam("b") String b) {

		return "test1" + a + b;
	}
}
